# eu_studies.csv was created using hard-coded values in the replication script,
# by partially running the data/raw/BhaDahHan2019/bhatti_data_recreate.R

source(here::here("code/load.R"))

us <- here("data/meta_analyses_raw/BhaDahHan2019/am_studies.csv") |>
    read.table(sep = ";", header = TRUE) |>
    select(study_id = STUDY_ID,
           study_year = PUB_YEAR,
           estimate = CACE,
           std.error = SE) |>
    mutate(subset = "United States")

eu <- here("data/meta_analyses_raw/BhaDahHan2019/eu_studies.csv") |>
    read.csv() |>
    select(estimate = CACE,
           std.error = CACE_se,
           study_id = label2) |>
    mutate(study_year = as.numeric(gsub(".*(\\d{4}).*", "\\1", study_id)),
           subset = "Europe")

bind_rows(us, eu) |>
    mutate(meta_id = "BhaDahHan2019",
           subfield = "CP",
           question = "Does door-to-door canvassing increase turnout?") |>
    write_csv(here("data", "meta_analyses_clean", "BhaDahHan2019.csv"))
